package yns.springboot.guide.demo.exception;


/**
 * 
 * 返回Code和Info的枚举
 *
 */
public enum ExceptionInfoEnum2 {
	EXCEPTION_TYPE_1(1, "EXCEPTION_TYPE_1"), 
	EXCEPTION_TYPE_2(2, "EXCEPTION_TYPE_2");

	private Integer type;
	private String info;

	ExceptionInfoEnum2(Integer type, String info) {
		this.type = type;
		this.info = info;
	}

	public Integer getType() {
		return this.type;
	}

	public String getInfo() {
		return this.info;
	}
	
	public static Integer getTypeByInfo(String info) {
		for (ExceptionInfoEnum2 enums : ExceptionInfoEnum2.values()) {
			if (enums.getInfo().equalsIgnoreCase(info)) {
				return enums.getType();
			}
		}
		return null;
	}
	
	public static String getInfoByType(Integer type) {
		for (ExceptionInfoEnum2 enums : ExceptionInfoEnum2.values()) {
			if (enums.getType().equals(type)) {
				return enums.getInfo();
			}
		}
		return null;
	}
}
